package com.myproj.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.myproj.service.EmpService;

@Controller
public class EmpController {
	@Autowired
	private EmpService emservice;

	@RequestMapping(value = "ulogin", method = RequestMethod.POST)
	public void elogin(HttpServletResponse res, HttpServletRequest req) {
		res.setContentType("text/html; charset=utf-8");
		String ename = req.getParameter("ename");
		String lastname = req.getParameter("eid");
		try {
			PrintWriter out = res.getWriter();
			out.print(emservice.empLogin(ename, lastname));
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	@RequestMapping(value = "findAll", method = RequestMethod.POST)
	public void listAllEmp(HttpServletResponse res, HttpServletRequest req) {
		res.setContentType("text/html; charset=utf-8");
		try {
			PrintWriter out = res.getWriter();
			out.print(emservice.findAll());
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	

}
